{
 "cells": [
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "## 第五次练习"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "+ 请务必交到exer5文件夹下，**谢绝交到master下**\n",
    "+ 请不要改动任何文件，拜托\n",
    "+ 请在11月7日前提交。"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "请写一下姓名和学号：\n",
    "+ 姓名  颜丙琦\n",
    "+ 学号  0165199"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "#### 题目一、贫困户模型\n",
    "+ 创建一个类，包含贫困户的义务教育保障、住房安全、饮水安全、肉蛋奶豆的四个属性\n",
    "+ 包含一个是否贫困的预测，如果四个属性有两个以上没有保障（>2)则输出为贫困户\n",
    "+ 对贫困户，采取相应措施（输入参数）对其进行帮扶，使其脱贫\n",
    "+ 至少生成三个实例\n"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 2,
   "metadata": {
    "collapsed": false
   },
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "\n",
      "贫困户\n",
      "需要进行住房补贴\n",
      "需要提供免费教育\n",
      "需要保障自来水\n",
      "\n",
      "贫困户\n",
      "需要进行住房补贴\n",
      "需要提供免费教育\n",
      "需要保障自来水\n",
      "需要进行健康帮扶\n",
      "\n",
      "非贫困户\n"
     ]
    }
   ],
   "source": [
    "class poverty(object):\n",
    "    def __init__(self,x1,x2,x3,x4):\n",
    "        self.house=x1\n",
    "        self.edu=x2\n",
    "        self.water=x3\n",
    "        self.health=x4\n",
    "    def arrange(self,house):\n",
    "        if house==0:\n",
    "            self.house=1\n",
    "        else:\n",
    "            self.house=0\n",
    "    def shangxue(self,edu):\n",
    "        if edu==0:\n",
    "            self.edu=1\n",
    "        else:\n",
    "            self.edu=0\n",
    "    def yinshui(self,water):\n",
    "        if water==0:\n",
    "            self.water=1\n",
    "        else:\n",
    "            self.water=0\n",
    "    def roudannai(self,protein):\n",
    "        if protein==0:\n",
    "            self.protein=1\n",
    "        else:\n",
    "            self.protein=0\n",
    "    def pinkunhu(self):\n",
    "        sum=0   \n",
    "        sum=self.house+self.edu+self.water+self.protein   \n",
    "        if sum>2:\n",
    "            print(\"\\n贫困户\") \n",
    "            if self.house==1:\n",
    "                print(\"需要进行住房补贴\")\n",
    "            if self.edu==1:\n",
    "                print(\"需要提供免费教育\")\n",
    "            if  self.water==1:\n",
    "                print(\"需要保障自来水\")\n",
    "            if  self.protein==1:\n",
    "                print(\"需要进行健康帮扶\")\n",
    "        else :\n",
    "            print(\"\\n非贫困户\")\n",
    "family1=poverty(1,1,0,1)\n",
    "family1.arrange(house=0)\n",
    "family1.shangxue(edu=0)\n",
    "family1.yinshui(water=0)\n",
    "family1.roudannai(protein=1)\n",
    "family1.pinkunhu()\n",
    "\n",
    "family2=poverty(1,1,0,1)\n",
    "family2.arrange(house=0)\n",
    "family2.shangxue(edu=0)\n",
    "family2.yinshui(water=0)\n",
    "family2.roudannai(protein=0)\n",
    "family2.pinkunhu()\n",
    "\n",
    "family3=poverty(1,1,0,1)\n",
    "family3.arrange(house=1)\n",
    "family3.shangxue(edu=1)\n",
    "family3.yinshui(water=1)\n",
    "family3.roudannai(protein=1)\n",
    "family3.pinkunhu()"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "#### 题目二: 学生信息\n",
    "+ 创建一个类，包含姓名、分数、睡眠时间三个属性\n",
    "+ 包含一个胖瘦的预测，如果分数>90，且睡眠时间少于6小时，输出“BMI可能偏大”，否则输出“体重正常”\n",
    "+ 为使得标准（90分、6小时）可以调整，标准应设为输入的参数\n",
    "+ 至少生成三个实例"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 20,
   "metadata": {
    "collapsed": false
   },
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "\n",
      "Abby BMI可能偏大\n",
      "\n",
      "Jackson 体重正常\n",
      "\n",
      "Ricky 体重正常\n"
     ]
    }
   ],
   "source": [
    "class student(object):\n",
    "    def __init__(self,name,score,hour):\n",
    "        self.name=name\n",
    "        self.score=score\n",
    "        self.hour=hour\n",
    "    def zhengchang(self,st1,st2):\n",
    "        if (self.score>st1)&(self.hour<st2):\n",
    "            print(\"\\n%s BMI可能偏大\"%self.name)\n",
    "        else:\n",
    "            print(\"\\n%s 体重正常\"%self.name)\n",
    "people1=student(\"Abby\",98,5)\n",
    "people1.zhengchang(90,6)\n",
    "\n",
    "people2=student(\"Jackson\",80,7)\n",
    "people2.zhengchang(90,6)\n",
    "\n",
    "people3=student(\"Ricky\",90,7)\n",
    "people3.zhengchang(80,6)"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "#### 题目三：“跑步社”成员类\n",
    "+ 创建一个“跑步社”成员类，以学生信息类为父类\n",
    "+ 添加一个属性为跑步\n",
    "+ 如果跑步时间大于30分钟，如果之前预测为“BMI可能偏大”，则输出为“趋向正常”\n",
    "+ 至少生成三个实例"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 17,
   "metadata": {
    "collapsed": false
   },
   "outputs": [
    {
     "data": {
      "text/plain": [
       "'趋向正常'"
      ]
     },
     "execution_count": 17,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "class running_club(student):\n",
    "    def __init__(self,name,score,hour,running):\n",
    "        super().__init__(name,score,hour)\n",
    "        self.running=running\n",
    "    def zhengchang(self,st1,st2):\n",
    "        if (self.score>st1)&(self.hour<st2):\n",
    "            if self.running>30:\n",
    "                return '趋向正常'          \n",
    "            else:\n",
    "                return 'BMI可能偏大'\n",
    "        else:\n",
    "            return '体重正常'\n",
    "\n",
    "people1=running_club(\"Abby\",98,5,40)\n",
    "people1.zhengchang(90,6)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 18,
   "metadata": {
    "collapsed": false
   },
   "outputs": [
    {
     "data": {
      "text/plain": [
       "'体重正常'"
      ]
     },
     "execution_count": 18,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "people2=running_club(\"Jackson\",80,7,35)\n",
    "people2.zhengchang(90,6)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 19,
   "metadata": {
    "collapsed": false
   },
   "outputs": [
    {
     "data": {
      "text/plain": [
       "'体重正常'"
      ]
     },
     "execution_count": 19,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "people3=running_club(\"Ricky\",90,7,16)\n",
    "people3.zhengchang(80,6)"
   ]
  }
 ],
 "metadata": {
  "kernelspec": {
   "display_name": "Python 3",
   "language": "python",
   "name": "python3"
  },
  "language_info": {
   "codemirror_mode": {
    "name": "ipython",
    "version": 3
   },
   "file_extension": ".py",
   "mimetype": "text/x-python",
   "name": "python",
   "nbconvert_exporter": "python",
   "pygments_lexer": "ipython3",
   "version": "3.6.0"
  }
 },
 "nbformat": 4,
 "nbformat_minor": 2
}
